const http=require('http');
const url=require('url');
const querystring=require('querystring');

let server=http.createServer((req,res)=>{
    let {pathname,query}=url.parse(req.url,true)
    console.log(`接收到了数据`,pathname,query)

    // POST数据
    let aBuffer=[];
    req.on('data',data=>{
        aBuffer.push(data)
    })
    req.on('end',end=>{
        //  data 是最终数据
        let data = Buffer.concat(aBuffer);
        const post = querystring.parse(data.toString())
        console.log(`POST数据是：`,post)
    })
    res.end()
})
server.listen(8080)